From 8821161c38664d6f43dbb1fe5139a92af1c93fe2 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 5 Jul 2005 22:34:07 +0000 Subject: [PATCH] Take window groups into account. (#309473, Diego Gonzalez) 2005-07-05 Matthias Clasen * gtk/gtkmenu.c (gtk_menu_grab_notify): Take window groups into account. (#309473, Diego Gonzalez) * gtk/gtkwindow.[hc]: Add a non-exported function to get the grab widget of a window group. --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ docs/reference/gtk/tmpl/gtkmain.sgml | 2 +- gtk/gtkmenu.c | 15 +++++++++++---- gtk/gtkwindow.c | 9 +++++++++ gtk/gtkwindow.h | 1 + 7 files changed, 46 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f27ec5403f..a42045ecd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-07-05 Matthias Clasen + + * gtk/gtkmenu.c (gtk_menu_grab_notify): Take window + groups into account. (#309473, Diego Gonzalez) + + * gtk/gtkwindow.[hc]: Add a non-exported function to + get the grab widget of a window group. + 2005-07-05 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_bin_expose): in the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f27ec5403f..a42045ecd1 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2005-07-05 Matthias Clasen + + * gtk/gtkmenu.c (gtk_menu_grab_notify): Take window + groups into account. (#309473, Diego Gonzalez) + + * gtk/gtkwindow.[hc]: Add a non-exported function to + get the grab widget of a window group. + 2005-07-05 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_bin_expose): in the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f27ec5403f..a42045ecd1 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2005-07-05 Matthias Clasen + + * gtk/gtkmenu.c (gtk_menu_grab_notify): Take window + groups into account. (#309473, Diego Gonzalez) + + * gtk/gtkwindow.[hc]: Add a non-exported function to + get the grab widget of a window group. + 2005-07-05 Kristian Rietveld * gtk/gtktreeview.c (gtk_tree_view_bin_expose): in the diff --git a/docs/reference/gtk/tmpl/gtkmain.sgml b/docs/reference/gtk/tmpl/gtkmain.sgml index ce4d115cca..c45bf6cca5 100644 --- a/docs/reference/gtk/tmpl/gtkmain.sgml +++ b/docs/reference/gtk/tmpl/gtkmain.sgml @@ -387,7 +387,7 @@ keyboard events are delivered to this widget. -Queries the current grab. +Queries the current grab of the default window group. @Returns: The widget which currently has the grab or %NULL if no grab is active. diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index 4096511b9d..de23fe7f66 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -4387,8 +4387,7 @@ gtk_menu_set_monitor (GtkMenu *menu, /** * gtk_menu_get_for_attach_widget: * @widget: a #GtkWidget - * - * Returns a list of the menus which are attached to this widget. + * * Returns a list of the menus which are attached to this widget. * This list is owned by GTK+ and must not be modified. * * Return value: the list of menus attached to his widget. @@ -4410,10 +4409,18 @@ static void gtk_menu_grab_notify (GtkWidget *widget, gboolean was_grabbed) { + GtkWidget *toplevel; + GtkWindowGroup *group; + GtkWidget *grab; + + toplevel = gtk_widget_get_toplevel (widget); + group = _gtk_window_get_group (GTK_WINDOW (toplevel)); + grab = _gtk_window_group_get_current_grab (group); + if (!was_grabbed) { - if (!GTK_IS_MENU (gtk_grab_get_current ())) - gtk_menu_shell_cancel (GTK_MENU_SHELL (widget)); + if (!GTK_IS_MENU_SHELL (grab)) + gtk_menu_shell_cancel (GTK_MENU_SHELL (widget)); } } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 47f5601805..9811973344 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6943,6 +6943,15 @@ _gtk_window_get_group (GtkWindow *window) } } +/* Return the current grab widget of the given group + */ +GtkWidget * +_gtk_window_group_get_current_grab (GtkWindowGroup *window_group) +{ + if (window_group->grabs) + return GTK_WIDGET (window_group->grabs->data); + return NULL; +} /* Derived from XParseGeometry() in XFree86 diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index a9871e59bf..6d60912c02 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -391,6 +391,7 @@ void _gtk_window_constrain_size (GtkWindow *window, gint *new_width, gint *new_height); GtkWindowGroup *_gtk_window_get_group (GtkWindow *window); +GtkWidget *_gtk_window_group_get_current_grab (GtkWindowGroup *window_group); void _gtk_window_set_has_toplevel_focus (GtkWindow *window, gboolean has_toplevel_focus); -- 2.30.2